package com.oreilly.android.taskmanager.tasks;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class TasksSQLiteOpenHelper extends SQLiteOpenHelper {

	public static final int VERSION = 1;
	public static final String DB_NAME = "tasks_db.sqlite";
	public static final String TASKS_TABLE = "tasks";
	public static final String TASK_ID = "id";
	public static final String TASK_TITLE = "name";
	public static final String TASK_DESCRIPTION = "description";
	public static final String TASK_COMPLETE = "complete";
	public static final String TASK_LATITUDE = "latitude";
	public static final String TASK_LONGITUDE = "longtitude";
	public static final String TASK_DUE_DATE = "due_date";
	public static final String TASK_LOCATION = "location";

	public TasksSQLiteOpenHelper(Context context) {
		super(context, DB_NAME, null, VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		createTable(db);

	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

	protected void createTable(SQLiteDatabase db) {
		db.execSQL("create table " + TASKS_TABLE + " (" + TASK_ID
				+ " integer primary key autoincrement not null," + TASK_TITLE
				+ " text, " + TASK_DESCRIPTION + " text, " + TASK_COMPLETE
				+ " text, " + TASK_DUE_DATE + " text, " + TASK_LATITUDE
				+ " float, " + TASK_LONGITUDE + " float," + TASK_LOCATION
				+ " text)");
	}
}
